const statusEnum = {
  'ENABLE': {
    type: 'success',
    name: '启用'
  },
  'DISABLE': {
    type: 'danger',
    name: '禁用'
  }
}
const sizeUnit = ['Bytes', 'KB', 'MB', 'GB', 'TB']
export default props => [
  {
    title: '线路',
    key: 'line_name'
  },
  {
    title: '车站',
    key: 'station_name'
  },
  {
    title: '场景名称',
    key: 'scene_name',
    tag: 'el-input',
  },
  {
    title: '文件版本',
    key: 'scene_version'
  },
  {
    title: '模型数量',
    key: 'model_number'
  },
  {
    title: '文件大小',
    key: 'file_size',
    format: (row, column, cellValue, index) => {
      const sizeType = parseInt(
        Math.floor(Math.log(cellValue) / Math.log(1024)).toString()
      )
      const size = (cellValue / Math.pow(1024, sizeType)).toFixed(2)
      return size + sizeUnit[sizeType]
    }
  },
  {
    title: '状态',
    key: 'status',
    render(h, { row }) {
      const config = statusEnum[row.status] || {}
      return (
        <el-tag type={config.type} size="small">
          {config.name || '-'}
        </el-tag>
      )
    }
  },
  {
    title: '上传人员',
    key: 'create_user'
  },
  {
    title: '上传时间',
    key: 'create_time',
    minWidth: '110px',
    showOverflowTooltip: true
  },
  {
    title: '备注',
    key: 'description',
  },
  {
    title: '操作',
    key: 'operation',
    minWidth: 150,
    render(h, { row }) {
      return (
        <div class="bwt-table-operation">
          {/* {(
            <el-link onClick={() => props.showDetail(row)}>
              详情
            </el-link>
          )} */}
          {(
            <el-link onClick={() => props.edit(row)}>
              编辑
            </el-link>
          )}
          {/* {(
            <el-button size="small" type="text" onClick={() => props.review(row)}>
              预览
            </el-button>
          )} */}
          {/* {(
            <el-button size="small" type="text" onClick={() => props.config(row)}>
              配置
            </el-button>
          )} */}
          {/* {(
            <el-button size="small" type="text" onClick={() => props.showLog(row)}>
              历史版本
            </el-button>
          )} */}
          {(
            <el-link class="danger" onClick={() => props.remove(row)}>
              删除
            </el-link>
          )}
        </div>
      )
    }
  }
]
